

#include "ly/object.hpp"

namespace ly {
// Object::Object(const Object& d) : m_id(0), sptr(0) {
//   //  attach to the manager if required
//   manager(d.manager());
// }

void Object::manager(manager_sptr p_manager) {
  auto sptr = mp_manager.lock();
  if (p_manager != sptr) {

    if (sptr) {
      sptr->release_object(m_id);
    }

    if (p_manager) {
      sptr = p_manager;
      m_id = sptr->next_id(shared_from_this());
    } else {
      sptr = 0;
      m_id = 0;
    }
  }
}

}  // namespace ly
